package cn.itcast.rabbitmq.util;

import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

public class ConnectionUtil {
    public static Connection getConnection()throws Exception{
        //创建连接工厂（设置rabbitMQ的连接参数）
        ConnectionFactory connectionFactory = new ConnectionFactory();
        //主机默认localhost
        connectionFactory.setHost("192.168.200.128");
        //连接端口默认5672
        connectionFactory.setPort(5672);
//        虚拟主机默认/
        connectionFactory.setVirtualHost("/");
//        用户名默认itcast
        connectionFactory.setUsername("guest");
//        用户密码默认itcast
        connectionFactory.setPassword("guest");
//        创建连接
        return connectionFactory.newConnection();
    }
}
